home *** CD-ROM | disk | FTP | other *** search
/ Software Vault: The Gold Collection / Software Vault - The Gold Collection (American Databankers) (1993).ISO / cdr01 / halcn305.zip / TESTBROW.PAS < prev    next >
Pascal/Delphi Source File  |  1993-07-27  |  4KB  |  147 lines

  1. program TestBrow;
  2. {------------------------------------------------------------------------------
  3.                               DBase Browser
  4.  
  5.        TESTBROW.PAS Copyright (c)  Richard F. Griffin
  6.  
  7.        20 July 1993
  8.  
  9.        102 Molded Stone Pl
  10.        Warner Robins, GA  31088
  11.  
  12.        -------------------------------------------------------------
  13.        This program demonstrates how dBase files may be browsed using
  14.        Griffin Solutions units.
  15.  
  16.        If the GSDMO_01.DBF file does not exist, the program will display a
  17.        a message that the file was not found and to run GSDMO_01 to make
  18.        the file.
  19.  
  20.        The program opens a dBase file and proceeds to browse the file.
  21.        Pressing F1 displays a list of commands available.
  22.  
  23. -------------------------------------------------------------------------------}
  24.  
  25. uses
  26.    GSXT_Bro,
  27.    GSOB_Var,
  28.    GSOBShel,
  29.    SmplStuf,
  30.    CRT,
  31.    DOS;
  32.  
  33. var
  34.    lnStart,
  35.    lnEnd    : word;
  36.    broCmd   : longint;
  37.    broLines : integer;
  38.    validcmd : boolean;
  39.    i : integer;
  40.    t : string;
  41.    th: string;
  42.    ch: char;
  43.  
  44. Procedure ShoBrowse;
  45. begin
  46.    GoToXY(1,1);
  47.    writeln(GetBrowseHeader(lnStart));
  48.    writeln(GetBrowseBar(lnStart));
  49.    for i := 1 to 23 do
  50.    begin
  51.       t := GetBrowseLine(i, lnStart);
  52.       gotoxy(1,i+2);
  53.       if t <> '' then write(t) else ClrEOL;
  54.    end;
  55.    ch := GetKey;
  56.    if (not GS_KeyI_Fuc) and (GS_KeyI_Chr >= #32) then
  57.             GS_KeyI_Chr := Kbd_Ret;
  58.  
  59.    case GS_KeyI_Chr of
  60.  
  61.       Kbd_F1   : begin
  62.                     ClrScr;
  63.                     gotoxy(22,7);
  64.                     writeln('The following commands are available:');
  65.                     writeln;
  66.                     writeln('':25,
  67.                             'Cursor Keys  - PgUp, PgDn, Up, Down,');
  68.                     writeln('':25,'               Right, Left');
  69.                     writeLn('':25,'Next Field   - Tab');
  70.                     writeLn('':25,'Prev Field   - Shift-Tab');
  71.                     writeLn('':25,'Record Start - Home');
  72.                     writeLn('':25,'Record End   - End');
  73.                     writeLn('':25,'Top of File  - Ctrl-Home');
  74.                     writeln('':25,'End of File  - Ctrl-End');
  75.                     writeln('':25,'Quit         - F10, Escape');
  76.                     WaitForKey;
  77.                     ClrScr;
  78.                  end;
  79.       Kbd_Home : begin
  80.                     lnStart := 1;
  81.                  end;
  82.       Kbd_End  : begin
  83.                     lnStart := 16384;         {beyond max record size}
  84.                     MoveBrowseRight(lnStart);
  85.                  end;
  86.       Kbd_CHom : begin
  87.                     UpdateBrowse(broTop);
  88.                  end;
  89.       Kbd_CEnd : begin
  90.                     UpdateBrowse(broBttm);
  91.                  end;
  92.       Kbd_PgUp : begin
  93.                     UpdateBrowse(broPgUp);
  94.                  end;
  95.       Kbd_PgDn : begin
  96.                     UpdateBrowse(broPgDn);
  97.                  end;
  98.       Kbd_UpAr : begin
  99.                     UpdateBrowse(broLnUp);
  100.                  end;
  101.       Kbd_DnAr : begin
  102.                     UpdateBrowse(broLnDn);
  103.                  end;
  104.       Kbd_RtAr : begin
  105.                     MoveBrowseRight(lnStart);
  106.                  end;
  107.       Kbd_LfAr : begin
  108.                     MoveBrowseLeft(lnStart);
  109.                  end;
  110.       Kbd_Tab  : begin
  111.                     TabBrowseRight(lnStart);
  112.                  end;
  113.       Kbd_RTb  : begin
  114.                     TabBrowseLeft(lnStart);
  115.                  end;
  116.       Kbd_Esc,
  117.       Kbd_F10  : validcmd := false;
  118.    end;
  119. end;
  120.  
  121. begin
  122.    ClrScr;
  123.    if not FileExist('GSDMO_01.DBF') then   {Check for the file}
  124.    begin
  125.       writeln('File GSDMO_01.DBF not found.  Run GSDMO_01 to create.');
  126.       halt;
  127.    end;
  128.                        {The 'Real' example starts here}
  129.  
  130.    Select(1);                     {Use record area 1 (the default)}
  131.    Use('GSDMO_01');               {Assign the dBase III file GSDMO_01}
  132.    SetDBFCacheOn;
  133.    lnStart := 1;
  134.    lnEnd := 79;
  135.    validCmd := true;
  136.    broCmd := broTop;
  137.    broLines := 23;
  138.    ClrScr;
  139.    StartBrowse(broLines, lnEnd);
  140.    UpdateBrowse(broCmd);
  141.    repeat
  142.       ShoBrowse;
  143.    until not validCmd;
  144.    ResetBrowse;
  145.    CloseDataBases;                {Close the file}
  146. end.
  147.